file chooser: Avoid a crash
authorMatthias Clasen <mclasen@redhat.com>
Sun, 31 Jan 2016 04:07:56 +0000 (23:07 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 31 Jan 2016 04:07:56 +0000 (23:07 -0500)
Since 39c2d12330b6d4405ca8a5599c12017c58626fcf,
priv->operation_mode == OPERATION_MODE_BROWSE no longer
guarantees that priv->browse_files_model is the current
model of the list - we are only switching the models after
loading the new directory. Avoid triggering the assertion
in show_and_select_files by checking if we have right model
before calling it.

https://bugzilla.gnome.org/show_bug.cgi?id=761209

gtk/gtkfilechooserwidget.c

index 127e18b47488ae4c8975a039ed7b0b4931d19cc7..d1a2ed8b364f107e5da43a2d87e26343c2b1d779 100644 (file)
@@ -5630,15 +5630,19 @@ gtk_file_chooser_widget_select_file (GtkFileChooser  *chooser,
   GtkFileChooserWidgetPrivate *priv = impl->priv;
   GFile *parent_file;
   gboolean same_path;
+  GtkFileSystemModel *fsmodel;
 
   parent_file = g_file_get_parent (file);
 
   if (!parent_file)
     return gtk_file_chooser_set_current_folder_file (chooser, file, error);
 
+  fsmodel = GTK_FILE_SYSTEM_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->browse_files_tree_view)));
+
   if (priv->operation_mode == OPERATION_MODE_SEARCH ||
       priv->operation_mode == OPERATION_MODE_RECENT ||
-      priv->load_state == LOAD_EMPTY)
+      priv->load_state == LOAD_EMPTY ||
+      priv->browse_files_model != fsmodel)
     {
       same_path = FALSE;
     }